package com.ljc.cjgl.entitiy.bbs;

import com.ljc.cjgl.entitiy.Course;
import com.ljc.cjgl.security.SysUser;
import org.springframework.data.annotation.CreatedBy;

import javax.persistence.*;
import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * Description: 帖子实体类
 * Author: JavaJun
 * Date: 2019-04-28 15:35
 */
@Entity
public class Article {

    // ID
    private Integer id;
    // 标题
    private String title;
    // 帖子内容
    private String content;
    // 课程
    private Course course;
    // 作者
    private SysUser sysUser;
    private Date inTime;
    private Date modifyTime;

    @Id
    @GeneratedValue
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Column(length = 150)
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Lob
    @Column(columnDefinition = "MEDIUMTEXT", nullable = true)
    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @ManyToOne
    @CreatedBy
    public Course getCourse() {
        return course;
    }

    public void setCourse(Course course) {
        this.course = course;
    }

    @ManyToOne
    @CreatedBy
    public SysUser getSysUser() {
        return sysUser;
    }

    public void setSysUser(SysUser sysUser) {
        this.sysUser = sysUser;
    }

    /**
     * Temporal注解的作用就是帮Java的Date类型进行格式化
     *  TemporalType.DATE——>实体类会封装成日期“yyyy-MM-dd”的 Date类型,映射为java.sql.Date
     *  TemporalType.TIME——>实体类会封装成时间“hh-MM-ss”的 Date类型,映射为java.sql.Time
     *  TemporalType.TIMESTAMP——>实体类会封装成完整的时间“yyyy-MM-dd hh:MM:ss”的 Date类型,映射为java.sql.TimeStamp
     */
    @Temporal(TemporalType.TIMESTAMP)
    public Date getInTime() {
        return inTime;
    }

    public void setInTime(Date inTime) {
        this.inTime = inTime;
    }

    @Temporal(TemporalType.TIMESTAMP)
    public Date getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(Date modifyTime) {
        this.modifyTime = modifyTime;
    }
}
